import { EcsSystem, filter, NodeComponent } from "db://pkg/@gamex/cc-ecs";
import { PlayerComponent } from "../component/PlayerComponent";
import { DestroyComponent } from "../component/DestroyComponent";
import { app } from "db://assets/app/app";



export class ItemSystem extends EcsSystem {
    private playerFilter = filter.all(PlayerComponent, NodeComponent).exclude(DestroyComponent);
    // 每8秒创建一个道具
    private pause = 8;

    protected execute(dt?: number, ...args: any[]): void {
        const playerEntity = this.find(this.playerFilter);
        if (!playerEntity) return;
        this.pause -= dt;
        if (this.pause > 0) return;
        this.pause = 8;
        app.controller.game.prop(playerEntity.getComponent(NodeComponent));
    }
}